/*
 * This is the private header file for HVACControl.C
 */
#ifndef HVAC_H
#define HVAC_H


#include <eZ80F91.h>

/********* Relay pin assignments *********/
// I would use PB 2,3,6,7 for heat/ac and PD 6,7 for fan
//I am looking at the document i sent  you a link to: http://www.zilog.com/docs/PS0280.pdf

#define HEAT_RELAYS_PORT			PB_DR
#define HEAT_RELAYS_PORT_DDR		PB_DDR
#define HEAT_RELAYS_PORT_ALT1		PB_ALT1
#define HEAT_RELAYS_PORT_ALT2		PB_ALT2

#define HEAT_ON_PIN_POS				0x03
#define HEAT_OFF_PIN_POS			0x02

#define AC_RELAYS_PORT				PC_DR
#define AC_RELAYS_PORT_DDR			PC_DDR
#define AC_RELAYS_PORT_ALT1			PC_ALT1
#define AC_RELAYS_PORT_ALT2			PC_ALT2

#define AC_ON_PIN_POS				0x01
#define AC_OFF_PIN_POS				0x03

#define FAN_RELAYS_PORT				PD_DR
#define FAN_RELAYS_PORT_DDR			PD_DDR
#define FAN_RELAYS_PORT_ALT1		PD_ALT1
#define FAN_RELAYS_PORT_ALT2		PD_ALT2

#define FAN_ON_PIN_POS				0x06
#define FAN_OFF_PIN_POS				0x07


/********* Temperature Settings ************/
#define HEAT_MIN_OFF_PERIOD 	210			// Minimum time HVAC must remain off
#define AC_MIN_OFF_PERIOD 		210			// to avoid damaging the system (in seconds)
											// This value based on existing thermostats

#define FAN_RUN_AFTER_AC		30			// Time in seconds that the fan needs to run after shutting off the AC

#define RELAY_WAIT_PERIOD_MS 	25			// In ms

#define MIN_TEMP_C 4
#define MAX_TEMP_C 25

#define MIN_TEMP_F 40
#define MAX_TEMP_F 90


// Default settings
#define DEFAULT_SET_TEMP 			70	// Degrees F
#define DEFAULT_HVAC_MODE 			OFF
#define DEFAULT_HVAC_STATE			IDLE
#define DEFAULT_FAN_MODE			FAN_AUTO
#define DEFAULT_FAN_STATE			FAN_IDLE
#define DEFAULT_HEATER_TYPE			GAS
#define DEFAULT_TEMP_VARIANCE		2	// Degrees F
#define DEFAULT_TEMP_UNIT			FAHRENHEIT
#define DEFAULT_OPERATION_MODE		HOLD
#define DEFAULT_POLLING_INTERVAL	15 // seconds

#endif